-
-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix preview bin directory for git bash #1009
Fix preview bin directory for git bash #1009
Conversation
The preview bin is not found on window using git for windows. The issue is that git bash is using a unix like path architecture (disk mounted in /mnt dir). The fix replace, path disk name with unix path to disk style, and `\` with `/`.
@janlazo Hi, sorry to bother you but do you think this is a proper fix? |
@@ -41,7 +41,8 @@ if s:is_win | |||
else | |||
let s:bin.preview = fnamemodify(s:bin.preview, ':8') | |||
endif | |||
let s:bin.preview = 'bash '.escape(s:bin.preview, '\') | |||
let git_bash_bin = 'bash /mnt/'.substitute(s:bin.preview, '\([A-Z]\):', '\L\1\e', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is /mnt/
here? What if git installed with another method? What if the bash executable is not git bash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best fix would probably be to write a Powershell script that would be use for windows.
This would require to bypass the execution policy, see. I'm not sure this can be done without admin rights.
If you are ok with this, i can create another PR with a Powershell script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with it but the powershell script should be cross-platform if possible so that it can be tested on Linux.
Something that doesn't require additional tools to be installed would be nice. |
What is the shell set in the vimrc, shell options for that shell, and the shell (environment) used to run vim/nvim? Windows allows forward slash for running binaries via executable path but bash and git need to be executed directly without the user's shell. Preview commands was coded to make it run a temporary batchfile which runs cmd.exe so changing to forward slash can only make things worse. |
@@ -41,7 +41,8 @@ if s:is_win | |||
else | |||
let s:bin.preview = fnamemodify(s:bin.preview, ':8') | |||
endif | |||
let s:bin.preview = 'bash '.escape(s:bin.preview, '\') | |||
let git_bash_bin = 'bash /mnt/'.substitute(s:bin.preview, '\([A-Z]\):', '\L\1\e', '') | |||
let s:bin.preview = substitute(git_bash_bin, '\', '/', 'g') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use mixed paths without using cygpath, ok. Problem is if it breaks the shortpath for Vim.
All are default in both vim and nvim, what exact option names you have in mind? shell? shellquote? shellxquote? shellredir?
But... it directly runs bash with preview.sh as a parameter, did I miss anything? |
Best to go with powershell if we're considering a different language that must work on Windows. batchfiles are hard to maintain and JS is not available by default. |
Preview command should work with vim/nvim defaults especially if the shell options like shellcmdflag and shellslash are left at their default values. It's unusual for it to fail unless there is a regression. IIRC, fzf-vim passes a preview command to fzf (binary). fzf parses the preview command for a placeholder but the parsing logic is for
|
Everything is default. And if you look into the issue I have posted results of plain bash calls with preview.sh as parameter. It just doesn't work with full path to preview.sh. #988 (comment) I suspect the issue is with WSL -- I have it installed and it (probably?) provides bash.exe in system32/ directory. And this bash.exe doesn't work with |
Is it enough to recommend the user to adjust their PATH so wsl bash is not found first? Does WSL bash have a unique text in the output of |
Not sure
|
I don't think so. It would be quite cumbersome -- my git and other tools paths are managed by scoop for example. Also I am not sure if wsl would work if I I put wsl bash path after git bash. |
What I know: bash in wsl has according to https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash you can check it in bash with:
I don't know how to invoke it from command line though. |
Hey thanks for the great work on fzf.
This PR is supposed to fix #988.
If you have suggestions, i can edit the code and test on my Windows computer.
The preview bin is not found on window using git for windows.
The issue is that git bash is using a unix like path architecture
(disk mounted in /mnt dir).
The fix replace, path disk name with unix path to disk style, and
\
with
/
.